package com.neuedu.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.neuedu.entity.Bed;
import com.neuedu.service.BedService;
import com.neuedu.vo.ResultJson;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 床位表 前端控制器
 * </p>
 *
 * @author wangyu
 * @since 2025-10-15
 */
@RestController
@RequestMapping("/bed")
public class BedController {
    @Resource
    BedService bedService;
    @GetMapping("/list")
    ResultJson<IPage<Bed>> list(Integer pageNo, Integer pageSize, String bedNo) {
        return ResultJson.success(bedService.list(pageNo, pageSize, bedNo));
    }
    @PostMapping("/add")
    ResultJson<Boolean> add(Bed bed) {
        return ResultJson.success(bedService.save(bed), "添加床位成功");
    }
    @PostMapping("/update")
    ResultJson<Boolean> update(Bed bed) {
        return ResultJson.success(bedService.updateById(bed), "修改床位成功");
    }
    @PostMapping("/delete")
    ResultJson<Boolean> delete(Integer id) {
        return ResultJson.success(bedService.removeById(id), "删除床位成功");
    }
    @GetMapping("/getById")
    ResultJson<Bed> getById(Integer id) {
        return ResultJson.success(bedService.getById(id));
    }
}
